package day08;

public class StringPlusDemo {
    public static void main(String[] args){
         appendStr();
         strPlus();
    }
    public static void strPlus(){
        String str = "";
        long before = System.currentTimeMillis();
        for(int i = 0;i<1000000;i++){
            str+=i;
        }
        System.out.println("str:"+(System.currentTimeMillis()-before)+"ms");
    }

    public static void appendStr(){
        StringBuilder builder = new StringBuilder();
        long before = System.currentTimeMillis();

        for(int i = 0;i<1000000;i++){
            builder.append(i);
        }
        System.out.println("append:"+(System.currentTimeMillis()-before)+"ms");
    }
}
